<?php

class Signup_form_mvc_model extends CI_Model{
    
    
    function __construct()
    {
        parent::__construct();
    }
    
    
    public function commit_new_user() {
        
        $user = new Testing\User;
        $user->setFirstName($this->input->post('firstname'));
        $user->setLastName($this->input->post('lastname'));
        $user->setPassword(md5($this->input->post('password')));
        $user->setEmail($this->input->post('email'));
        $user->setWebsite($this->input->post('website'));
        $user->setCreated(new DateTime());

        // standard way in CodeIgniter to access a library in a controller: $this->library_name->member->memberFunction()
        // save the object to database, so that it can obtain its ID
        $this->doctrine->em->persist($user);

        $this->doctrine->em->flush();
        
        //$this->load->view('signup_form_success_view');
        
    }
    

    /*
	public function setTableDefinition() {
		$this->hasColumn('firstname', 'string', 255, array('unique' => 'false'));
                $this->hasColumn('lastname', 'string', 255, array('unique' => 'false'));
		$this->hasColumn('password', 'string', 255);
		$this->hasColumn('email', 'string', 255, array('unique' => 'true'));
                $this->hasColumn('website', 'string', 255, array('unique' => 'false'));
	}

	public function setUp() {
		$this->setTableName('testtable1');
		$this->actAs('Timestampable');
                //$this->hasMutator('password', '_encrypt_password');
	}
        
        protected function _encrypt_password($value) {
             $salt = '#*seCrEt!@-*%';
             $this->_set('password', md5($salt . $value));
             //Note: For mutators to work, auto_accessor_override option needs to be enabled. We have already done it, in our plugin file doctrine_pi.php.

        }
     * 
     */
    
    
}




